package yl.hs.bmipfull.controllers.construction;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.finance.IReceiptSettleService;
import yl.hs.bmipfull.service.finance.IShipSettleService;
import yl.hs.bmipfull.viewmodels.PageQuery;
import yl.hs.bmipfull.viewmodels.WebResult;
import yl.hs.bmipfull.viewmodels.salemanmage.ConstructionSignModel;

/*
 * ConstructionSettleController
 * @category
 * @author 谢景广
 * @date 2022-04-23
 */
@RequestMapping("/construction/settle")
@Api(value = "工地系统", tags = "工地系统——发货结算")
@RestController
public class ConstructionSettleController extends ControllerBase {

    @PostMapping("query/{rowNum}/{page}")
    @ApiOperation(value = "查询所有远程下单信息", notes = "分页查询所有远程下单信息" )
    public WebResult queryList(@PathVariable("rowNum")int rowNum, @PathVariable("page")int page, @RequestBody PageQuery query){
        try {
           var result = settleSvc.queryConstructionPage(query, rowNum, page);
           return success("OK",result);
        }
        catch (Exception ee){
            return error(ee);
        }
    }

    @RequestMapping(value = "getNotSignedCount",method =RequestMethod.GET)
    @ApiOperation(value = "查询所有远程下单信息", notes = "分页查询所有远程下单信息" )
    public WebResult GetNotSignedCount(){
        try {
            var result = settleSvc.GetConstructionNotSignedCount(new PageQuery());
            return success("OK",result);
        }
        catch (Exception ee){
            return error(ee);
        }
    }
    @PostMapping("sign")
    @ApiOperation(value = "查询所有远程下单信息", notes = "分页查询所有远程下单信息" )
    public WebResult signSettleOrder(@ApiParam(value = "提交信息") @RequestBody ConstructionSignModel model){
        try {
            var result = settleSvc.saveSignInfo(model);
            return success("OK",result);
        }
        catch (Exception ee){
            return error(ee);
        }
    }
    @ApiOperation(value = "结算单详情数据接口", notes = "查询结算单明细和附加项")
    @RequestMapping(path = "/Details/{settleSN}", method = RequestMethod.GET)
    public WebResult findDetailsBySN(@ApiParam("结算单标识") @PathVariable String settleSN){
        try {
            var result = settleSvc.querySettleDetailsBySettleSN(settleSN);
            return success("ok",result);
        }
        catch (Exception ee){
            return error(ee);
        }
    }
    @Autowired
    IShipSettleService settleSvc;
}
